package com.neusoft.cloudstreamfeign.controller;

import com.neusoft.cloudstreamfeign.dto.DeliveryProcess;
import com.neusoft.cloudstreamfeign.dto.Result;
import com.neusoft.cloudstreamfeign.dto.RouteInfo;
import com.neusoft.cloudstreamfeign.dto.RouteProcess;
import com.neusoft.cloudstreamfeign.feign.DeliveryServiceClient;
import com.neusoft.cloudstreamfeign.param.DeliverInfoCreatOrUpdateParam;
import com.neusoft.cloudstreamfeign.param.DeliverInfoDeleteParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * 物流服务Feign控制器
 * 通过负载均衡调用员工服务
 */
@RestController
@RequestMapping("/feign/stream")
public class StreamFeignController {

    @Autowired
    @Qualifier("com.neusoft.cloudstreamfeign.feign.DeliveryServiceClient")
    private DeliveryServiceClient deliveryServiceClient;

    @GetMapping("/deliveryInfo/list")
    public Result list(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
        return deliveryServiceClient.list(pageNum, pageSize);
    }

    @PostMapping("/deliveryInfo/create")
    public Result create(@RequestBody DeliverInfoCreatOrUpdateParam deliveryInfo) {
        return deliveryServiceClient.create(deliveryInfo);
    }

    @PostMapping("/deliveryInfo/update")
    public Result update(@RequestBody DeliverInfoCreatOrUpdateParam deliveryInfo) {
        return deliveryServiceClient.update(deliveryInfo);
    }

    @PostMapping("/deliveryInfo/delete")
    public Result delete(@RequestBody DeliverInfoDeleteParam deliverInfoDeleteParam) {
        return deliveryServiceClient.delete(deliverInfoDeleteParam);
    }

    @GetMapping("/deliveryInfo/status")
    public Result listByStatus(@RequestParam("status") Integer status, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
        return deliveryServiceClient.listByStatus(status, pageNum, pageSize);
    }

    @GetMapping("/deliveryInfo/order")
    public Result getByOrderNumber(@RequestParam("orderNumber") String orderNumber) {
        return deliveryServiceClient.getByOrderNumber(orderNumber);
    }

    @GetMapping("/deliveryProcess/list")
    public Result list1(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, @RequestParam(value = "deliveryId",  required = false) Long deliveryId) {
        return deliveryServiceClient.list1(pageNum, pageSize, deliveryId);
    }

    @PostMapping("/deliveryProcess/create")
    public Result create1(@RequestBody DeliveryProcess deliveryProcess) {
        return deliveryServiceClient.create1(deliveryProcess);
    }

    @PostMapping("/deliveryProcess/update")
    public Result update1(@RequestBody DeliveryProcess deliveryProcess) {
        return deliveryServiceClient.update1(deliveryProcess);
    }

    @PostMapping("/deliveryProcess/delete")
    public Result delete1(@RequestBody DeliveryProcess deliveryProcess) {
        return deliveryServiceClient.delete1(deliveryProcess);
    }

    @GetMapping("/routeInfo/list")
    public Result list2(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, @RequestParam(value = "routeCode", required = false) String routeCode) {
        return deliveryServiceClient.list2(pageNum, pageSize, routeCode);
    }

    @PostMapping("/routeInfo/create")
    public Result create2(@RequestBody RouteInfo routeInfo) {
        return deliveryServiceClient.create2(routeInfo);
    }

    @PostMapping("/routeInfo/update")
    public Result update2(@RequestBody RouteInfo routeInfo) {
        return deliveryServiceClient.update2(routeInfo);
    }

    @PostMapping("/routeInfo/delete")
    public Result delete2(@RequestBody RouteInfo routeInfo) {
        return deliveryServiceClient.delete2(routeInfo);
    }

    @GetMapping("/routeProcess/list")
    public Result list3(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize")
    Integer pageSize,    @RequestParam(value = "deliveryId", required = false) Long deliveryId, @RequestParam(value = "routeId",  required = false) Long routeId) {
        return deliveryServiceClient.list3(pageNum, pageSize, deliveryId, routeId);
    }

    @PostMapping("/routeProcess/create")
    public Result create3(@RequestBody RouteProcess routeProcess) {
        return deliveryServiceClient.create3(routeProcess);
    }

    @PostMapping("/routeProcess/update")
    public Result update3(@RequestBody RouteProcess routeProcess) {
        return deliveryServiceClient.update3(routeProcess);
    }

    @PostMapping("/routeProcess/delete")
    public Result delete3(@RequestBody RouteProcess routeProcess) {
        return deliveryServiceClient.delete3(routeProcess);
    }



}
